package main

import "fmt"

func readLineInt(num int) []int {
	in := make([]int, 0, num)
	var d int
	for i := 0; i < num; i++ {
		fmt.Scan(&d)
		in = append(in, d)
	}
	return in
}
func readLineStr() string {
	var in string
	fmt.Scan(&in)
	return in
}
func main() {
	num := readLineInt(1)[0]
	for i := 0; i < num; i++ {
		s := readLineStr()
		if len(s) > 10 {
			fmt.Printf("%c%d%c\n", s[0], len(s)-2, s[len(s)-1])
		} else {
			fmt.Println(s)
		}
	}
}
